package com.vip8.recorder.api.model.base;

import lombok.Data;

import java.util.List;

@Data
public class MultiResult<T> extends Result {
    private List<T> data;
    private int total;

    public MultiResult() {
    }

    public MultiResult(int code, boolean success, String message) {
        super(code, success, message);
    }

    public MultiResult(List<T> data) {
        super(SUCCESS_CODE, true, "");
        this.data = data;
    }


    public static MultiResult success() {
        return new MultiResult(null);

    }

    public static <T> MultiResult<T> success(List<T> data, int total) {
        MultiResult<T> result = new MultiResult(data);
        result.total = total;
        return result;
    }

    public static <T> MultiResult<T> success(List<T> data) {
        MultiResult<T> result = new MultiResult(data);
        return result;
    }

    public static MultiResult failure() {
        return new MultiResult(FAIL_CODE, false, FAIL_DEFAULT_MESSAGE);
    }

    public static MultiResult failure(String msg) {
        return new MultiResult(FAIL_CODE, false, msg);
    }


}
